import unittest
from utils.tools import add
from parameterized import parameterized
from utils.tools import build_add_json_data
from utils.tools import build_add_json_data2

data = [(1, 2, 3), (1, 3, 4), (2, 4, 6)]

class TestParam(unittest.TestCase):
    @parameterized.expand(data)
    def test_add1(self, a, b, expected):
        print(f'a：{a}，b：{b}，expected：{expected}')
        # 断言方法是来自于继承的测试类
        self.assertEqual(add(a, b), expected)


# 需要读取json文件-元素为列表
class TestParamJson(unittest.TestCase):
    @parameterized.expand(build_add_json_data())
    def test_add1(self, a, b, expected):
        print(f'a：{a}，b：{b}，expected：{expected}')
        self.assertEqual(add(a, b), expected)

# 需要读取json文件-元素为字典
class TestParamJson2(unittest.TestCase):
    @parameterized.expand(build_add_json_data2())
    def test_add1(self, a, b, expected):
        print(f'a：{a}，b：{b}，expected：{expected}')
        self.assertEqual(add(a, b), expected)


if __name__ == '__main__':
    unittest.main()